package com.reps.service;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;

import com.reps.RepsStartMain;

/**
 * @author chl
 * @date 2018/7/18 16:00
 */
public class SaveRecordInfo {

    private static File file;

    static{
         file=new File(RepsStartMain.dtSaveFilePath);
        if(!file.exists())
        {
            file.getParentFile().mkdirs();
            try
            {
                file.createNewFile();
                saveOneRecord(RepsStartMain.preData);
            }catch (Exception e)
            {
                e.printStackTrace();
            }

        }
    }

    public synchronized static void saveOneRecord(String s)
    {
    	OutputStreamWriter fw = null;
        BufferedWriter writer = null;
        try {
            fw = new OutputStreamWriter(new FileOutputStream(file,true),"UTF-8");
            writer = new BufferedWriter(fw);
                writer.write(s.trim());
                writer.newLine();//换行
        } catch (IOException e) {
            e.printStackTrace();
        }catch (Exception e){
            e.printStackTrace();
        }finally{
            try {
                writer.close();
                fw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }


}
